package com.wsoft.mq.test.sample.direct;

import com.wsoft.mq.constant.ImConstant;
import com.wsoft.utils.RabbitMQUtil;
import com.wsoft.websocket.entity.TestMessage;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * @Author z001
 * @Date 2025/1/7 15:36
 */
@RestController
@RequestMapping("/direct")
public class DirectSample {
    @Resource
    private RabbitTemplate rabbitTemplate;
    @Resource
    private RabbitMQUtil rabbitMqUtil;


    @PostMapping("/sendMessage1")
    public void sendMessage1(@RequestBody TestMessage testMessage){
        CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());

        rabbitMqUtil.sendMessage(ImConstant.IM_FORM_USER_SINGLE_DIRECT_EXCHANGE
                , ImConstant.IM_FORM_USER_SINGLE_KEY,
                "direct模式发送消息");

//
//        rabbitTemplate.convertAndSend(RabbitDirectConstant.DIRECT_EXCHANGE
//                , RabbitDirectConstant.DIRECT_ROUTING_KEY_1+"!!",
//                testMessage,correlationData);
    }
}
